<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<link rel="stylesheet" href="${initParam.root }/css/board/main_boardList.css">
<script type="text/javascript">
	$(document).ready(function(){
		$("#write_btn").click(function(){
			location.href="board.do?command=freeWriteMove";
		}); // 글쓰기click
		$("#goSearchButton").click(function(){
			if($("#searchFreeSelect").val()==""){
				alert("검색조건을 선택하세요");
				return;
			}else if($("#searchFreeText").val()==""){
				alert("검색조건을 입력하세요");
				return;
			}
			location.href="board.do?command=freeSearch&searchFreeSelect="+
					   $("#searchFreeSelect").val()+"&searchFreeText="+$("#searchFreeText").val();
		   });//찾기click
		$("#deleteContent").click(function(){
			if($("#freeListForm :radio[name=delContent]:checked").length==0){
				alert("삭제할 게시물을선택하세요");
				return; 	
			}else if(confirm("선택된 게시물을 삭제하시겠습니까?")){
				location.href="board.do?command=freeDeleteContentByAdmin&b_no="+ $(':input:radio[name=delContent]:checked').val();
			}   
		 });//게시글삭제click
	}); // ready
	</script>
<form action="${initParam.root }/board.do" method="post" id="freeListForm" name="freeListForm">
<div id="전체틀">
<header>
	<h2>
		<img src="${initParam.root }/img/main/main-freeboard-title.gif"
			alt="RapidXHTML" />
	</h2>
</header>
	<div id="board">
		<table id="head">
			<tr>
				<c:if test="${sessionScope.loginMember.mvoLogin.m_type=='a'}">
					<td align="center"width="5%">선택</td>
				</c:if>
				<td width="10%" class="main_td">글번호</td><td width="50%">제목</td><td width="15%">작성자</td><td width="15%">작성일</td><td width="10%">조회</td>
			</tr>
		</table>
		<c:if test="${requestScope.map.lvo.list!='null' }">
		<table id="body">
			<c:forEach items="${requestScope.map.lvo.list }" var="freeList" varStatus="i">
			<c:choose>
				<c:when test="${i.count%5==0}">
					<tr class="tr_line"> 
				</c:when>
				<c:otherwise>
					<tr class="tr_noline">		
				</c:otherwise>
			</c:choose> 
			<c:if test="${sessionScope.loginMember.mvoLogin.m_type=='a'}">
			<td align="center" width="5%">
			<input type="radio" name="delContent" value="${freeList.b_no}" id="b_no" ></td>
			</c:if>
			<td width="10%">${freeList.b_no}</td>
				
				<%-- bvo에 relevel이 0이 아니면 답변글이므로 relevel만큼 공백으로 제목을 밀어준다  --%>
				<td width="50%" class="tr_title">
				<c:if test="${freeList.b_relevel!=0}">
					<c:forEach begin="0" end="${freeList.b_relevel}" step="1">&nbsp;</c:forEach>
					<img src="${initParam.root }/img/paging/reply.jpg">
				</c:if>
				<a href="${initParam.root }/board.do?command=freeShowContent&bno=${freeList.b_no }
				&pageNo=${requestScope.map.lvo.pagingBean.nowPage}&mid=${freeList.m_id}" name="showCon">${freeList.b_title}</a>
					
					<c:if test="${freeList.newfilename!=null }">
						<a href="${initParam.root}/board.do?command=fileDownload&newfilename=${freeList.newfilename }
						&orgfilename=${freeList.orgfilename }">
							<img alt="#" src="${initParam.root }/img/paging/main-board-file.gif">
						</a>
					</c:if>
					<c:if test="${freeList.totalReply!=0 }">
						[${freeList.totalReply }]
					</c:if>
					<c:if test="${requestScope.map.today==freeList.b_date}">
							<img alt="#" src="${initParam.root }/img/paging/main-board-new.gif">
					</c:if>
				</td>
				<td width="15%" class="td_name">${freeList.b_writer}</td>
				<td width="15%" class="td_date">${freeList.b_date}</td>
				<td width="10%">${freeList.b_cnt}</td>
			</tr>
			</c:forEach>
		</table>
		</c:if>
			<c:if test="${sessionScope.loginMember.mvoLogin.m_type=='a'}">
				<img alt="게시글삭제" src="${initParam.root }/img/paging/delete_btn.jpg" id="deleteContent">
			</c:if>  
			<c:if test="${sessionScope.loginMember!=null }">
				<div id="write">		
				<img alt="글쓰기" src="${initParam.root }/img/paging/write_btn.jpg" id="write_btn">
				</div>
			</c:if>
		
		<div align="center"><br>
		 <c:if test="${requestScope.map.lvo.pagingBean.previousPageGroup }">
		 <a href= "${initParam.root }/board.do?command=findAllFreeforPaging&pageNo=${requestScope.map.lvo.pagingBean.startPageOfPageGroup-1}">
		 <img src="${initParam.root }/img/paging/left_arrow_btn.gif"></a>
		 </c:if>
		<c:forEach var="i" 	
		begin="${requestScope.map.lvo.pagingBean.startPageOfPageGroup}"
		 end="${requestScope.map.lvo.pagingBean.endPageOfPageGroup}">
		 <c:choose>
		 <c:when test="${requestScope.map.lvo.pagingBean.nowPage!=i}">
		 <a href="${initParam.root }/board.do?command=findAllFreeforPaging&pageNo=${i}">${i}</a>
		 </c:when>
		 <c:otherwise>
		${i}
		</c:otherwise>
		</c:choose>
		</c:forEach>	 
		 <c:if test="${requestScope.map.lvo.pagingBean.nextPageGroup}">
		 <a href="${initParam.root }/board.do?command=findAllFreeforPaging&pageNo=${requestScope.map.lvo.pagingBean.endPageOfPageGroup+1}">
		 <img src="${initParam.root }/img/paging/right_arrow_btn.gif"></a>
		 </c:if>
		</div><br><br>
		
		<div id="search" align="center">
			<select id="searchFreeSelect">
				<option value="">선택하세요</option>
				<option value="b_title">제목</option>
				<option value="b_writer">작성자</option>
			</select>
			    <input type="text" id="searchFreeText" >
			    <input type="button" name="searchButton" id="goSearchButton" value="검색">
		</div>
		
	</div>
</div>
</form>